import request from '@/utils/request'
import { get } from 'sortablejs'

// 查询采购计划列表
export function listPlan(query) {
  return request({
    url: '/procured/plan/list',
    method: 'get',
    params: query
  })
}

// 查询采购计划详细
export function getPlan(planId) {
  return request({
    url: '/procured/plan/' + planId,
    method: 'get'
  })
}

// 查询采购计划详情页面订单相关信息
export function getOrderDetails(data) {
  return request({
    url: '/procured/plan/orders/details',
    method: 'get',
    params: data
  })
}

// 新增采购计划
export function addPlan(data,componentPath) {
  return request({
    url: '/procured/plan',
    method: 'post',
    params: {
      componentPath,
    },
    data: data
  })
}

// 修改采购计划
export function updatePlan(data) {
  return request({
    url: '/procured/plan',
    method: 'put',
    data: data
  })
}

// 采购计划下单时修改采购计划相关数据
export function updatePlanStatus(data) {
  return request({
    url: '/procured/plan/procured/orders',
    method: 'put',
    data: data
  })
}

// 删除采购计划
export function delPlan(planId) {
  return request({
    url: '/procured/plan/' + planId,
    method: 'delete'
  })
}

export function getSelectVendorTreeList() {
  return request({
    url: '/procured/plan/selectVendorTreeList',
    method: 'get'
  })
}

export function getSelectCompanyTreeList() {
  return request({
    url: '/procured/plan/selectCompanyTreeList',
    method: 'get'
  })
}

export function getSelectDeptById(deptId) {
  return request({
    url: '/procured/plan/selectDeptById/' + deptId,
    method: 'get'
  })
}

export function getSelectPreWarehouseTreeList() {
  return request({
    url: '/procured/plan/selectPreWarehouseTreeList',
    method: 'get'
  })
}

export function getSelectMonetaryTreeList() {
  return request({
    url: '/procured/plan/selectMonetaryTreeList',
    method: 'get'
  })
}

// 批量查询产品
export function getProductById(id) {
  return request({
    url: '/procured/plan/selectProductListById/' + id,
    method: 'get'
  })
}

// 核准
export function getUpdateProcuredPlanStatus(planIds, flay) {
  return request({
    url: '/procured/plan/updateProcuredPlanStatus/' + planIds + "/" + flay,
    method: 'get',
  })
}

// 查询采购产品列表
export function getSelectTbProcuredProductList(query) {
  return request({
    url: '/procured/plan/selectTbProcuredProductList',
    method: 'get',
    params: query
  })
}

//批量查询采购产品数据
export function getSelectTbProcuredProductListById(id) {
  return request({
    url: '/procured/plan/selectTbProcuredProductListById/' + id,
    method: 'get'
  })
}

//修改选择的状态
export function getUpdateProcuredProductSelectedStatus(id, flay) {
  return request({
    url: '/procured/plan/updateProcuredProductSelectedStatus/' + id + "/" + flay,
    method: 'put',
  })
}

//
export function getInsertProcuredOrders(data) {
  return request({
    url: '/procured/plan/insertProcuredOrders',
    method: 'post',
    data: data
  })
}

//查询要撤销下单的采购单号
export function getSelectProcuredOrdersPlanId(planId) {
  return request({
    url: '/procured/plan/selectProcuredOrdersPlanId/' + planId,
    method: 'get'
  })
}

//撤销下单
export function getDeleteProcuredOrdersByOrdersNumber(ordersNumber) {
  return request({
    url: '/procured/plan/deleteProcuredOrdersByOrdersNumber/' + ordersNumber,
    method: 'delete'
  })
}

//撤销下单判断计划状态
export function getUpdateProcuredPlanOrdersNumber(ordersNumber, flay) {
  return request({
    url: '/procured/plan/updateProcuredPlanOrdersNumber/' + ordersNumber + "/" + flay,
    method: 'put',
  })
}

// 待我审核
export function getPlanWaitProcessList(query) {
  return request({
    url: '/procured/plan/getPlanWaitProcuredProcessList',
    method: 'get',
    params: query
  })
}
// 我已审核
export function getPlanReadyProcessList(query) {
  return request({
    url: '/procured/plan/getPlanReadyProcuredProcessList',
    method: 'get',
    params: query
  })
}
// 我发布审核
export function getPlanMyProcessList(query) {
  return request({
    url: '/procured/plan/getPlanMyProcuredProcessList',
    method: 'get',
    params: query
  })
}
// 更新审核结果
export function updatePlanProcessStatus(data) {
  return request({
    url: '/procured/plan/updateProcuredPlanProcessStatus',
    method: 'put',
    data: data,
  })
}
// 查询审核流程记录
export function getPlanProcessList(procuredPlanId) {
  return request({
    url: '/procured/plan/getProcuredPlanProcessList/' + procuredPlanId,
    method: 'get',
  })
}
// 审核记录
export function selectPlanProcessLogList(query) {
  return request({
    url: '/procured/plan/selectPlanProcessLogList',
    method: 'get',
    params: query
  })
}
// 查看采购计划的采购商品详细
export function getPlanProducts(planId) {
  return request({
    url: '/procured/plan/' + planId + '/products' ,
    method: 'get'
  })
}
